﻿
#region Usings

using PolyGameEngine.GamePieces;
using PolyGameEngine.GamePieces.Common;
using PolyGameEngine.Tools;

using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace PolyMorph.CustomGamePieces
{
    public class SmallPieceFromTexture : TextureGamePiece
    {
        Texture2D spikeTexture;
        public SmallPieceFromTexture(PhysicsGame PhysicsGame, World World, Material Material, Texture2D ShapeTexture, Vector2 Position, float Rotation, int saveLineIndex, string GPID) :
            base(PhysicsGame, World, Material, ShapeTexture, Position, Rotation, 1, saveLineIndex, GPID)
        {
            spikeTexture = ShapeTexture;
        }

        public override bool HandleDefaultCollision(Fixture ThisFixture, Fixture OtherFixture, Contact Contact)
        {
            if (GPID.Contains("Spike") && OtherFixture.UserData!=null&&
                OtherFixture.UserData.GetType().IsSubclassOf(typeof(GamePiece))&&
                ((GamePiece)(OtherFixture.UserData)).material.Identifier.Contains("Plastic"))
            {
                AudioMan.PlayCue("Pop");
                LevelEditor.Level.Reload();
            }
            return base.HandleDefaultCollision(ThisFixture, OtherFixture, Contact);
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
        }
    }
}
